$(document).ready(function() {
	//读取cookie
	var cart = getCookie("cart");
	var goodsObj = countPrice();
	var goodsIndex = goodsObj.index;
	var goodsPrice = goodsObj.price;
	var goodsNum = goodsObj.goodsNum;
	console.log(goodsObj)
	if (cart) {
		var goodsList = JSON.parse(cart)
		//渲染列表
		var html = '';
		goodsList.forEach(function(item) {
			html +=
				"<li class='clearfix'><div class='goodsImg fl'>"+
				"<img src="+item.goodsImg+" ></div>"+
				"<div class='fr goodsText'><p class='goodsTitle'>"+item.goodsName+"</p>"+
				"<p class='goodsInfo'>"+item.goodsInfo+"</p><div class='goodsPriceAll'>"+
				"<span class='goodsPrice'>"+item.goodsPrice+"</span> x <span class='goodsNum'>"+item.num+"</span>"+
				"</div></div></li>";
			$(".goodsNum,.cartNum").text(goodsNum);
			$(".goodsPrice").text("￥"+goodsPrice);
		});
		$('.cart_content').html(html);
		$('.cart_content').find(".goodsPriceAll").each(function(index,item){
			$(item).removeClass("cartStyle");
		})
		$('.cart_content').find("li").each(function(index,item){
			$(item).removeClass("cartBgcolor")
			$(item).find(".goodsTitle").removeClass("cartTitleStyle")
		})
		$('.cart_content').find("li").eq(goodsIndex).addClass("cartBgcolor");
		$('.cart_content').find("li").eq(goodsIndex).find(".goodsTitle").addClass("cartTitleStyle");
		$('.cart_content').find(".goodsPriceAll").eq(goodsIndex).addClass("cartStyle");
	}
})
